package org.skydiveapp2;

import android.os.Bundle;
import android.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;

public class BaseExpandableListFragment extends Fragment
{
	
	private OnChildClickListener onChildClickListener = new ExpandableListView.OnChildClickListener()
	{
		@Override
		public boolean onChildClick(ExpandableListView parent, View v,
				int groupPosition, int childPosition, long id) 
		{
			return onRigClick(parent, v, groupPosition, childPosition, id);
		}
	};
	
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
	    		Bundle savedInstanceState)
	{	
	    // Inflate the layout for this fragment
	    View view = inflater.inflate(R.layout.expandable_list_view, container, false);
	    		
		initializeUI(view);
		
		return view;
	}
	
	protected void initializeUI(View view)
	{	
		ExpandableListView eListView = (ExpandableListView) view.findViewById(R.id.ExpandableListView);
		eListView.setOnChildClickListener(onChildClickListener);
	}
	
	@Override
	public void onResume()
	{
		super.onResume();
	}
  
    protected void onTopButtonClick()
    {
    	// do nothing
    }
    
    protected void onBottomButtonClick()
    {
    	// do nothing
    }
    
	public ExpandableListView getExpandableListView()
	{
		ExpandableListView eListView = (ExpandableListView) getView().findViewById(R.id.ExpandableListView);
		
		return eListView;
	}
	
    public boolean onRigClick(android.widget.ExpandableListView parent, View v, int groupPosition, int childPosition, long id)
    {
    	return true;
    }
    
    public void setListAdapter(ExpandableListAdapter adapter)
    {
    	getExpandableListView().setAdapter(adapter);
    }
}
